{include file="../include.tpl"}
<body>
{literal}
<script>
$(function() {
		$( "input[type=submit], a, button" )
			.button()
			.click(function(event) {
			    var bid = $(event.target)[0].id;
			    $("#ui-id-1").html("创建车款");
			    $("#name").val("");

			    if(bid=="createUser")
			    {
			    	$("#dialog-form").dialog("open");
			    }
			    else if(bid.indexOf("editUser")!=-1)
			    {
			        //alert(document.getElementById("officalprice").value);
			        var id = bid.replace("editUser","");
			        $("#editId").val(id);
			        $("#ui-id-1").html("编辑车款");
			        $("#name").val($("#tdName"+id).html());
			    	$("#dialog-form").dialog("open");
			    }
			    else if(bid.indexOf("delUser")!=-1)
			    {
			        //alert("mmmm");
			        if(confirm("确认删除吗？"))
			        {
						var id = bid.replace("delUser","");
			    		$.get("?act=data&op=ajaxDelCarMode&id="+id,function(data)
			    		{
			    	    	var json = eval("("+data+")");
			    	    	if(json.st=="ok")
			    	    	{
			    	    	    alert(json.msg);
			    	    	    window.location=window.location;
			    	    	}
			    	    	else if(json.st=="err")
			    	    	{
			    	    	    alert(json.msg);
			    	    	}
			    		});
			        }
			    }
		});
		$( "#dialog-form" ).dialog({
			autoOpen: false,
			height: 300,
			width: 380,
			modal: true,
			buttons: {
				"保存": function() {
					var bValid = true;
                    if($("#name").val()=="")
                    {
                       $("#td_msg_name").html("必填项");
                       bValid = false;
                    }
					if(bValid ){
					    var obj = $(this);
					    var roleName = $("#selMenus").find("option:selected").text()
						$.post("?act=data&op=ajaxSaveCarMode&id="+$("#editId").val(),{name:$("#name").val()},function(data)
						{
						    var json = eval("("+data+")");
						    if(json.st=="ok")
						    {
								alert("保存成功");
								obj.dialog( "close" );
								window.location=window.location;
							}
							else if(json.st=="err1")
							{
								alert("保存失败：已经存在");
							}
							else if(json.st=="err2")
							{
								alert("保存失败：车款不能为空");
							}
						}); 
					}
				},
				"取消": function() {
					$(this).dialog( "close" );
				}
			},
			close: function() {
				
			}
		});
		 
});
</script>
{/literal}
<div id="dialog-form" title="创建车款">
	<form>
<fieldset>
       <table >
       <tr><td height="40px">车款：</td><td><input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" style="width:200px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>

       </table>
</fieldset>
	<input type="hidden" id="editId" value=""/>
	</form>
</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">车款管理</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="left_txt">当前位置：车款管理</td>
          </tr>
          <tr>
            <td height="20"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
              <tr>
                <td></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" height="55" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="10%" height="55" valign="middle"><img src="images/title.gif" width="54" height="55"></td>
                <td width="90%" valign="top"><span class="left_txt2">在这里，您可以创建或删除车款</span>
                <br/><button id="createUser">创建车款</button></td>
              </tr>
            </table></td>
          </tr>
		  <tr>
            <td height="20"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
              <tr><td></td></tr></table>
            </td>
          </tr>
          <tr>
            <td>
            <div id="users-contain" class="ui-widget">
	<h1>车款列表 共计:{$total}条</h1>
	<table id="users" class="ui-widget ui-widget-content">
		<thead>
			<tr class="ui-widget-header ">
				<th width="50px">编号</th>
				<th width="250px">车款</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
              {section name=sec1 loop=$data}
              <tr>
              <td>{$data[sec1].disId}</td>
              <td id="tdName{$data[sec1].id}">{$data[sec1].name}</td>
              <td><button id="editUser{$data[sec1].id}">编辑</button>&nbsp;&nbsp;&nbsp;&nbsp;<button id="delUser{$data[sec1].id}">删除</button></td>
              </tr>
              <input type="hidden" id="hidTypeId{$data[sec1].id}" value="{$data[sec1].typeId}"/>
              {/section}
		</tbody>
	</table>
</div>
 </td>
          </tr>
        </table>
          </td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</body>
